package com.qiwx.pigeon.adapter.query;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.qiwx.pigeon.R;
import com.qiwx.pigeon.adapter.home.ICageInterface;
import com.qiwx.pigeon.data.vo.CageProduceBean;

import java.util.List;

/**
 * @description
 * @Author qiwx
 * @Date 2020-04-03 21:06
 * 查询鸽笼详情
 **/
public class CageAdapter extends BaseQuickAdapter<CageProduceBean, BaseViewHolder> {

    ICageInterface iCageInterface;

    public CageAdapter(int layoutResId) {
        super(layoutResId);
    }

    public CageAdapter(int layoutResId, List<CageProduceBean> data) {
        super(layoutResId, data);
    }

    public void setICageInterface(ICageInterface iCageInterface) {
        this.iCageInterface = iCageInterface;
    }

    @Override
    protected void convert(BaseViewHolder holder, CageProduceBean bean) {
        int pos = holder.getLayoutPosition();

        holder.setText(R.id.txt_number, bean.getC_number() + "");
        holder.setText(R.id.layEggAmount, "" + bean.getLayEggAmount() + "");
        holder.setText(R.id.egg_amount1, "" + bean.getEggAmount1());
        holder.setText(R.id.egg_amount2, "" + bean.getEggAmount2());
        holder.setText(R.id.wujing2, "" + bean.getWujing2());
        holder.setText(R.id.shoujing2, "" + bean.getShoujing2() + "");
        holder.setText(R.id.sijing2, "" + bean.getSijing2());
        holder.setText(R.id.shoujing2sijing1, "" + bean.getShoujing2sijing1());
        holder.setText(R.id.shoujing2wujing1, "" + bean.getShoujing2wujing1());
        holder.setText(R.id.wujing2sijing1, "" + bean.getWujing2sijing1());
        holder.setText(R.id.shoujing1, "" + bean.getShoujing1());
        holder.setText(R.id.sijing1, "" + bean.getSijing1());
        holder.setText(R.id.wujing1, "" + bean.getWujing1());
        holder.setText(R.id.bfd2cpd, "" + (bean.getFd_breaken()
                + bean.getYd_breaken()
                + bean.getCd_breaken()
                + bean.getCz_breaken()));
        holder.setText(R.id.wudan, "" + (bean.getYd_wd()
                + bean.getFd_wd()
                + bean.getCd_wd()
                + bean.getCz_wdwz()));
        holder.setText(R.id.bad_egg, "" + (bean.getYd_bad()
                + bean.getFd_bad()
                + bean.getCd_bad()
                + bean.getCz_bad()));
        holder.getView(R.id.btn_eliminate).setOnClickListener(v -> {
            if (iCageInterface != null) {
                iCageInterface.onSelectId(pos, pos, 0);
            }

        });
        holder.getView(R.id.btn_lay_egg_record).setOnClickListener(v -> {
            if (iCageInterface != null) {
                iCageInterface.onSelectId(pos, pos, 1);
            }
        });

    }
}